package com.chujian.framework.starter.aliyun;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.profile.DefaultProfile;
import com.chujian.framework.starter.aliyun.oss.AliOssClient;
import com.chujian.framework.starter.aliyun.oss.AliyunOssAccount;
import com.chujian.framework.starter.aliyun.oss.AliyunOssProperties;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @author ：chujian
 * @date ：2020-08-10
 * @description：阿里云自动装配
 */
@EnableConfigurationProperties({
        AliyunAccountProperties.class,
        AliyunOssProperties.class
})
@AllArgsConstructor
public class AliyunAutoConfiguration {

    @Autowired
    AliyunAccountProperties aliyunAccountProperties;

    @Autowired
    AliyunOssProperties ossProperties;

    @Bean
    @ConditionalOnMissingBean
    public AliOssClient aliOssClient() {
        return new AliOssClient(aliyunAccountProperties, ossProperties);
    }

    @Bean
    @ConditionalOnMissingBean
    public AliyunOssAccount aliyunOssAccount() {
        return new AliyunOssAccount(aliyunAccountProperties, ossProperties);
    }

}
